package com.payment.web.controller.system;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.payment.common.annotation.Log;
import com.payment.common.base.AjaxResult;
import com.payment.common.enums.BusinessType;
import com.payment.common.page.TableDataInfo;
import com.payment.common.utils.ExcelUtil;
import com.payment.framework.web.base.BaseController;
import com.payment.system.domain.IndustryMcc;
import com.payment.system.service.IIndustryMccService;


/**
 * 行业MCC 信息操作处理
 * 
 * @author payment
 * @date 2019-05-09
 */
@Controller
@RequestMapping("/system/industryMcc")
public class IndustryMccController extends BaseController
{
    private String prefix = "system/industryMcc";
	
	@Autowired
	private IIndustryMccService industryMccService;
	
	@RequiresPermissions("system:industryMcc:view")
	@GetMapping()
	public String industryMcc()
	{
	    return prefix + "/industryMcc";
	}
	
	/**
	 * 查询行业MCC列表
	 */
	@RequiresPermissions("system:industryMcc:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(IndustryMcc industryMcc)
	{
		startPage();
        List<IndustryMcc> list = industryMccService.selectIndustryMccList(industryMcc);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出行业MCC列表
	 */
	@RequiresPermissions("system:industryMcc:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(IndustryMcc industryMcc)
    {
    	List<IndustryMcc> list = industryMccService.selectIndustryMccList(industryMcc);
        ExcelUtil<IndustryMcc> util = new ExcelUtil<IndustryMcc>(IndustryMcc.class);
        return util.exportExcel(list, "industryMcc");
    }
	
	/**
	 * 新增行业MCC
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存行业MCC
	 */
	@RequiresPermissions("system:industryMcc:add")
	@Log(title = "行业MCC", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(IndustryMcc industryMcc)
	{		
		return toAjax(industryMccService.insertIndustryMcc(industryMcc));
	}

	/**
	 * 修改行业MCC
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		IndustryMcc industryMcc = industryMccService.selectIndustryMccById(id);
		mmap.put("industryMcc", industryMcc);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存行业MCC
	 */
	@RequiresPermissions("system:industryMcc:edit")
	@Log(title = "行业MCC", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(IndustryMcc industryMcc)
	{		
		return toAjax(industryMccService.updateIndustryMcc(industryMcc));
	}
	
	/**
	 * 删除行业MCC
	 */
	@RequiresPermissions("system:industryMcc:remove")
	@Log(title = "行业MCC", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(industryMccService.deleteIndustryMccByIds(ids));
	}


	@PostMapping("/checkIndustryMcc")
	@ResponseBody
	public String checkIndustryMcc(String industryMcc,String id)
	{
		return industryMccService.checkIndustryMcc(industryMcc,id);
	}
}
